<%@ include file="/common/taglibs.jsp"%>

<title><fmt:message key="personList.title"/></title>
<content tag="heading"><fmt:message key="personList.heading"/></content>
<meta name="menu" content="PersonMenu"/>

<script type="text/javascript">
    function clearForm() {
      theForm = $('searchPerson');
      if (document.all || document.getElementById) {
        for (i = 0; i < theForm.length; i++) {
          var tempobj = theForm.elements[i];
          if (tempobj.type.toLowerCase() == "text") {
	          tempobj.value = '';
	      }
        }
       }
       return true;
    }
</script>
<!-- add the search buttons -->
<form:form action="persons.html" commandName="person" method="post" id="searchPerson">
  <div class="filter">
  <div class="line">
  <label for="personId">ID </label><form:input path="personId"/>
  </div>
  <div class="line">
  <label for="rfid">RFID</label><form:input path="rfid"/>
  </div>  
  <div class="line">
  <label for="firstName">First Name </label><form:input path="firstName"/>
  </div>
  <div class="line">
  <label for="lastName">Last Name </label><form:input path="lastName"/>
  </div>
  <div class="line">
  <label for="email">Email </label><form:input path="email"/>
  </div>
  <div class="line">
  <label for="phoneHome">Phone</label><form:input path="phoneHome"/>
  </div>
  <div class="line">
  <label for="searchAddress.address1">Address </label><form:input path="searchAddress.address1"/>
  </div>
  <div class="line">
  <label for="searchAddress.city">City </label><form:input path="searchAddress.city"/>
  </div>
  <div class="line">
  <label for="searchAddress.state">State</label> <form:input path="searchAddress.state" size="2"/>
  </div>
  <div class="line">
  <label for="searchAddress.zip">Zip </label><form:input path="searchAddress.zip" size="5"/>
  </div>
  <div class="line">
  <label for="searchPrimary">Search Primary Only </label><form:checkbox path="searchPrimary"/>
  </div>
  <div class="line">
  		Peron Status:
		<form:select path="personStatus">
            <form:option value="" label="--Please Select--"/>
            <form:option value="Active" label="Active"/>
            <form:option value="Inactive" label="Inactive"/>
        </form:select>
  </div>
  <div class="line">
  Exclude Verified Members <form:checkbox path="searchVerified"/>
  </div>
  <div class="line">
<form:radiobutton path="searchMemberYear" value="2011"/>  2011 Member
<form:radiobutton path="searchMemberYear" value="2012"/>  2012 Member
<form:radiobutton path="searchMemberYear" value="2013"/>  2013 Member
<form:radiobutton path="searchMemberYear" value="2014"/>  2014 Member
<form:radiobutton path="searchMemberYear" value="2015"/>  2015 Member
<form:radiobutton path="searchMemberYear" value="2016"/>  2016 member
  </div>
  <div class="line">
  		Org:
		<form:select path="subOrg">
            <form:option value="" label="--Please Select--"/>
            <form:options items="${subOrgs}" itemValue="id" itemLabel="fullName"/>
        </form:select>
  </div>
  <div class="line">
  		Role:
		<form:select path="role">
            <form:option value="" label="--Please Select--"/>
            <form:options items="${roles}" itemValue="id" itemLabel="name"/>
        </form:select>
  </div>
  <input type="submit" value="submit" style="margin-right: 5px"/>
  <input type="submit" value="clear" onclick="javascript:clearForm();return false;" style="margin-right: 5px"/>
  </div>
</form:form>
<c:set var="buttons">
    <input type="button" style="margin-right: 5px"
        onclick="location.href='<c:url value="/editPerson.html"/>'"
        value="<fmt:message key="button.add"/>"/>

    <input type="button" onclick="location.href='<c:url value="/mainMenu.html"/>'"
        value="<fmt:message key="button.done"/>"/>
</c:set>

${buttons}

<display:table name="personList" cellspacing="0" cellpadding="0" requestURI=""
    id="personList" pagesize="25" class="table personList" export="true">
	<display:column titleKey="person.personId" sortable="true" sortProperty="personId">
         <c:choose>
         <c:when test="${personList.primary eq null}">
         	<c:set var="editurl" value="editPerson.html?personId=${personList.personId}"/>
         </c:when>
         <c:otherwise>
         	<c:set var="editurl" value="editRelationship.html?primaryPersonId=${personList.primary.personId}&personId=${personList.personId}"/>
         </c:otherwise>
         </c:choose>
         <a href="${editurl}">${personList.personId}</a>
	</display:column>
	<%--
    <display:column property="personId" escapeXml="true" sortable="true"
        url="${editurl}" paramId="personId" paramProperty="personId"
        titleKey="person.personId"/>
    --%>

    <display:column property="firstName" escapeXml="true" sortable="true"
         titleKey="person.firstName"/>
    <display:column property="lastName" escapeXml="true" sortable="true"
         titleKey="person.lastName"/>
<%--
    <display:column property="dateOfBirth" escapeXml="true" sortable="true"
         titleKey="person.dateOfBirth"/>
    <display:column property="gender" escapeXml="true" sortable="true"
         titleKey="person.gender"/>

    <display:column escapeXml="false" sortable="true" sortProperty="email"
         titleKey="person.email">
         <div class="line">${personList.email}</div>
         <div class="line">${personList.email2}</div>
    </display:column>
    <display:column escapeXml="false" sortable="true" sortProperty="phoneHome"
         title="phone">
         <c:if test="${personList.phoneHome ne null}">
	         <div class="line">${personList.phoneHome}(H)</div>
         </c:if>
         <c:if test="${personList.phoneWork ne null}">
         <div class="line">${personList.phoneWork}(W)</div>
         </c:if>
         <c:if test="${personList.phoneMobile ne null}">
	         <div class="line">${personList.phoneMobile}(M)</div>
		</c:if>
         <c:if test="${personList.phoneFax ne null}">
         <div class="line">${personList.phoneFax}(F)</div>
         </c:if>
    </display:column>
--%>
    <display:column property="email" escapeXml="true" sortable="true"
         titleKey="person.email"/>
    <display:column property="email2" escapeXml="true" sortable="true"
         titleKey="person.email2"/>
    <display:column property="phoneHome" escapeXml="true" sortable="true"
         titleKey="person.phoneHome"/>
    <display:column property="phoneWork" escapeXml="true" sortable="true"
         titleKey="person.phoneWork"/>
    <display:column property="phoneMobile" escapeXml="true" sortable="true"
         titleKey="person.phoneMobile"/>
    <display:column property="phoneFax" escapeXml="true" sortable="true"
         titleKey="person.phoneFax"/>
<%--
    <display:column property="createdDate" escapeXml="true" sortable="true"
         titleKey="person.createdDate"/>
    <display:column property="updatedDate" escapeXml="true" sortable="true"
         titleKey="person.updatedDate"/>
    <display:column property="residentStartDate" escapeXml="true" sortable="true"
         titleKey="person.residentStartDate"/>
    <display:column property="citizen" escapeXml="true" sortable="true"
         titleKey="person.citizen"/>
    <display:column property="updatedBy" escapeXml="true" sortable="true"
         titleKey="person.updatedBy"/>
--%>
    <display:column property="personStatus" escapeXml="true" sortable="true"
         titleKey="person.personStatus"/>
<%--
    <display:column property="employerName" escapeXml="true" sortable="true"
         titleKey="person.employerName"/>
--%>
    <display:column property="primaryPerson" escapeXml="true" sortable="true"
         titleKey="person.primaryPerson"/>
    <display:setProperty name="paging.banner.item_name" value="person"/>
    <display:setProperty name="paging.banner.items_name" value="persons"/>
</display:table>

${buttons}

<script type="text/javascript">
    highlightTableRows("personList");
</script>
